﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace FileImportSystem2
{
    internal class AppConfig
    {
        #region 路径
        /// <summary>
        /// 主数据库路径
        /// </summary>
        public readonly static string dbMainPath = Path.Combine(
           GetSafeAppDataPath(),
           "db",
           "d.db"
        );
        /// <summary>
        /// 分月保存数据库文件夹
        /// </summary>
        public readonly static string dbMonFd = Path.Combine(
           GetSafeAppDataPath(),
           "db",
           "month"
        );


        /// <summary>
        ///     查询输出路径
        /// </summary>
        /// <returns>输出路径</returns>
        public static string GetSafeAppDataPath()
        {


            string appDataPath = Path.GetDirectoryName(Environment.ProcessPath) // 程序启动路径
                ?? Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) // appdata 路径
                ?? Environment.GetEnvironmentVariable("APPDATA")// APPDATA 环境变量
                ?? string.Empty;


            // 3. 降级方案1：基于UserProfile拼接
            if (string.IsNullOrEmpty(appDataPath))
            {
                string userProfile = Environment.GetEnvironmentVariable("UserProfile") ?? string.Empty;
                if (!string.IsNullOrEmpty(userProfile))
                {
                    appDataPath = Path.Combine(userProfile, "AppData", "Roaming");
                }
            }

            // 4. 降级方案2：应用安装目录
            if (string.IsNullOrEmpty(appDataPath))
            {
                appDataPath = AppDomain.CurrentDomain.BaseDirectory;
            }

            // 确保路径格式合法
            return Path.GetFullPath(appDataPath);
        }

        #endregion

        #region 其他参数

        /// <summary>
        /// 需要覆盖结算对象的对象明细
        /// </summary>
        public static string[] shenzhouDxList = new string[]
        {
            "炫丽彩",
            "钟晓萍"
        };

        #endregion



    }
}
